#include "PCH.h"
#include "..\Common.h"

AboutDialog::AboutDialog(HINSTANCE hAppInstance, int DlgResourceId)
{
	hInstance = hAppInstance;
	ResourceId = DlgResourceId;
}

BOOL AboutDialog::HandleMessage(UINT WindowMessage, WPARAM wParam, LPARAM lParam)
{
	switch(WindowMessage) {
		case WM_CLOSE:
			return OnClose(wParam, lParam);
		case WM_COMMAND:
			return OnCommand(wParam, lParam);
		case WM_INITDIALOG:
			return OnInitDialog(wParam, lParam);
		case WM_NCDESTROY:
			return OnNcDestroy(wParam, lParam);
		default:
			return FALSE;
	}
}

BOOL AboutDialog::OnCommand(WPARAM wParam, LPARAM lParam)
{
	switch(LOWORD(wParam)) {
		case COMMAND_OK:
			DestroyWindow(WindowHandle);

			return FALSE;
		default:
			return FALSE;
	}
}

BOOL AboutDialog::OnClose(WPARAM wParam, LPARAM lParam)
{
	DestroyWindow(WindowHandle);

	return FALSE;
}

BOOL AboutDialog::OnInitDialog(WPARAM wParam, LPARAM lParam)
{
	SetForegroundWindow(WindowHandle);
	SetClassLongPtr(WindowHandle, GCLP_HICON, (LONG_PTR)LoadIcon(hInstance, MAKEINTRESOURCE(ICON_ATH16)));

	return FALSE;
}

BOOL AboutDialog::OnNcDestroy(WPARAM wParam, LPARAM lParam)
{
	LRESULT lResult = DefWindowProc(WindowHandle, WM_NCDESTROY, wParam, lParam);

	SetWindowLongPtr(WindowHandle, GWLP_USERDATA, 0);

	delete this;

	return (BOOL)lResult;
}
